package supermarket;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
         ArrayList<Commodity> list = new ArrayList<>();// 商品库存集合
        // 初始化库存中的商品
        list.add(new Commodity("1001", "吉百芝麻油", 9.5, "125ml", 200));
        list.add(new Commodity("1002", "雀巢奶香咖啡", 1.5, "13g", 200));
        list.add(new Commodity("1003", "脉动水蜜桃", 7.0, "1.5l", 150));
        list.add(new Commodity("1004", "白沙糖", 2.5, "70g", 170));
        list.add(new Commodity("1005", "桃李熟切片", 6.5, "400g", 101));
        list.add(new Commodity("1006", "白玉黄豆芽", 2.4, "350g", 201));
        list.add(new Commodity("1007", "白玉内酯豆腐", 1.0, "400g", 151));
        list.add(new Commodity("1008", "哇哈哈", 5.5, "600ml", 100));
        list.add(new Commodity("1009", "芬达水", 6.9, "550ml", 180));
        list.add(new Commodity("1010", "脉动水", 4.5, "350ml", 135));
        try {
            XMLEncoder xmlEncoder=new XMLEncoder(new FileOutputStream("C:\\Users\\风之恺\\Desktop\\supermarket.xml"));
            xmlEncoder.writeObject(list);
            xmlEncoder.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
